<!--{template common/header}-->

<!--{if $type == 'qrcode'}-->
<link rel="stylesheet" href="{$_G['siteurl']}source/plugin/unifiedpay/style.css">
<script src="static/js/qrcode/qrcode.min.js"></script>
<script src="//cdn.staticfile.org/layer/3.1.1/layer.min.js"></script>
<script src="//cdn.staticfile.org/clipboard.js/1.7.1/clipboard.min.js"></script>

<div class="header cl">
	<div class="mz"><a href="javascript:history.back();"><i class="dm-c-left"></i></a></div>
	<h2>{$channel_name}{lang unifiedpay:payment_mobile}</h2>
	<div class="my"><a href="<!--{if $_G['setting']['mobile']['mobilehotthread']}--><!--{if !empty($_G['setting']['grid']['showgrid'])}-->forum.php<!--{else}-->forum.php?mod=guide&view=newthread<!--{/if}--><!--{else}-->forum.php?forumlist=1<!--{/if}-->"><i class="dm-house"></i></a></div>
</div>

<!--{if $pay_channel == 'wechat'}-->

<div class="qrcode-box qrcode-logo">
    <img src="static/image/common/wechatpay_logo.svg" />
</div>
<div class="qrcode-box">
    <div class="qrcode-alert">
        {lang unifiedpay:wechatpay_tip1}
    </div>
    <div id="pay-qrcode" class="qrcode-img"></div>
    <div class="qrcode-alert">
        {lang unifiedpay:wechatpay_tip2}
    </div>
    <div class="text-payurl"><a href="{$pay_url}">{$pay_url}</a></div>
    <button type="button" id="copy-btn" data-clipboard-text="{$pay_url}" class="qrcode-btn">{lang unifiedpay:copybtn}</button>&nbsp;
    <button type="button" onclick="window.location.href='weixin://'" class="qrcode-btn qrcode-btn-green">{lang unifiedpay:openwechat}</button>
</div>
<div class="qrcode-box">
    {lang unifiedpay:wechatpay_tip3}
</div>
<script>
    var clipboard = new Clipboard('#copy-btn');
	clipboard.on('success', function(e) {
		layer.msg('{lang unifiedpay:copy_succeed}');
	});
	clipboard.on('error', function(e) {
		layer.msg('{lang unifiedpay:copy_failed}');
	});
</script>

<!--{elseif $pay_channel == 'alipay'}-->

<div class="qrcode-box qrcode-logo">
    <img src="static/image/common/alipay_logo.svg" />
</div>
<div class="qrcode-box">
    <div class="amount">￥<em style="font-size: 36px;">{$money}</em></div>
    <div id="pay-qrcode" class="qrcode-img"></div>
    <button type="button" onclick="openApp()" class="qrcode-btn qrcode-btn-block">{lang unifiedpay:open_alipay_app}</button>
    <button type="button" onclick="checkresult()" class="qrcode-btn qrcode-btn-block qrcode-btn-green">{lang unifiedpay:check_result}</button>
</div>
<script>
    var url_scheme = 'alipays://platformapi/startapp?appId=20000067&url=' + encodeURIComponent('{$pay_url}');
    function openApp(){
		window.location.href = url_scheme;
		layer.msg('{lang unifiedpay:opening_alipay}', {shade: 0,time: 1000});
	}
</script>

<!--{elseif $pay_channel == 'qpay'}-->

<div class="qrcode-box qrcode-logo">
    <img src="static/image/common/qpay_logo.svg" />
</div>
<div class="qrcode-box">
    <div class="amount">￥<em style="font-size: 36px;">{$money}</em></div>
    <div id="pay-qrcode" class="qrcode-img"></div>
    <button type="button" onclick="openApp()" class="qrcode-btn qrcode-btn-block">{lang unifiedpay:open_qq_app}</button>
    <button type="button" onclick="checkresult()" class="qrcode-btn qrcode-btn-block qrcode-btn-green">{lang unifiedpay:check_result}</button>
</div>
<script>
    var url_scheme = 'mqqapi://forward/url?src_type=web&style=default&=1&version=1&url_prefix='+window.btoa('{$pay_url}');
    function openApp(){
		window.location.href = url_scheme;
		layer.msg('{lang unifiedpay:opening_qq}', {shade: 0,time: 1000});
	}
</script>

<!--{/if}-->

<script>
    new QRCode(document.getElementById('pay-qrcode'), {
        text: '{$pay_url}',
        width: 180,
        height: 180,
        colorDark: '#000000',
        colorLight: '#FFFFFF',
        correctLevel: QRCode.CorrectLevel.H
    });
    function loadmsg() {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{$_G['siteurl']}plugin.php?id=unifiedpay:status&out_biz_no={$out_biz_no}",
            success: function (data) {
                if (data.code == 1) {
					layer.msg('{lang unifiedpay:payment_success_msg}', {icon: 16,shade: 0.1,time: 15000});
					setTimeout(window.location.href=data.url, 1000);
                }else{
                    setTimeout(loadmsg, 2000);
                }
            }
        });
    }
    function checkresult() {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{$_G['siteurl']}plugin.php?id=unifiedpay:status&out_biz_no={$out_biz_no}",
            success: function (data) {
                if (data.code == 1) {
					layer.msg('{lang unifiedpay:payment_success_msg}', {icon: 16,shade: 0.1,time: 15000});
					setTimeout(window.location.href=data.url, 1000);
                }else{
                    layer.msg('{lang unifiedpay:undead_payment_msg}', {shade: 0,time: 1500});
                }
            }
        });
    }
    window.onload = function(){
        if(typeof openApp == 'function'){
            openApp();
        }
		setTimeout(loadmsg, 4000);
	}
</script>

<!--{elseif $type == 'scheme'}-->

<link rel="stylesheet" href="{$_G['siteurl']}source/plugin/unifiedpay/style.css">
<script src="//cdn.staticfile.org/layer/3.1.1/layer.min.js"></script>
<div class="header cl">
	<div class="mz"><a href="javascript:history.back();"><i class="dm-c-left"></i></a></div>
	<h2>{$channel_name}{lang unifiedpay:payment_mobile}</h2>
	<div class="my"><a href="<!--{if $_G['setting']['mobile']['mobilehotthread']}--><!--{if !empty($_G['setting']['grid']['showgrid'])}-->forum.php<!--{else}-->forum.php?mod=guide&view=newthread<!--{/if}--><!--{else}-->forum.php?forumlist=1<!--{/if}-->"><i class="dm-house"></i></a></div>
</div>
<div class="qrcode-box qrcode-logo">
    <img src="static/image/common/wechatpay_logo.svg" />
</div>
<div class="qrcode-box">
    <div class="amount">￥<em style="font-size: 36px;">{$money}</em></div>
    <div class="qrcode-alert" style="margin: 20px 0;">
        {lang unifiedpay:wechatminipay_tip}
    </div>
    <button type="button" onclick="openApp()" class="qrcode-btn qrcode-btn-block">{lang unifiedpay:continue_payment}</button>
    <button type="button" onclick="checkresult()" class="qrcode-btn qrcode-btn-block qrcode-btn-green">{lang unifiedpay:check_result}</button>
</div>
<script>
    var url_scheme = '{$pay_url}';
    function openApp(){
		window.location.href = url_scheme;
		layer.msg('{lang unifiedpay:opening_wechatminiapp}', {shade: 0,time: 1000});
	}
    function loadmsg() {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{$_G['siteurl']}plugin.php?id=unifiedpay:status&out_biz_no={$out_biz_no}",
            success: function (data) {
                if (data.code == 1) {
					layer.msg('{lang unifiedpay:payment_success_msg}', {icon: 16,shade: 0.1,time: 15000});
					setTimeout(window.location.href=data.url, 1000);
                }else{
                    setTimeout(loadmsg, 2000);
                }
            }
        });
    }
    function checkresult() {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{$_G['siteurl']}plugin.php?id=unifiedpay:status&out_biz_no={$out_biz_no}",
            success: function (data) {
                if (data.code == 1) {
					layer.msg('{lang unifiedpay:payment_success_msg}', {icon: 16,shade: 0.1,time: 15000});
					setTimeout(window.location.href=data.url, 1000);
                }else{
                    layer.msg('{lang unifiedpay:undead_payment_msg}', {shade: 0,time: 1500});
                }
            }
        });
    }
    window.onload = function(){
        window.location.href=url_scheme;
		setTimeout(loadmsg, 4000);
	}
</script>

<!--{elseif $type == 'html'}-->
{$pay_url}
<!--{else}-->
<script type="text/javascript">
    window.location.replace('{$pay_url}');
</script>
<!--{/if}-->

<!--{template common/footer}-->